home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
mc51bugs
/
q37632
< prev
next >
Wrap
Text File
|
1988-11-14
|
2KB
|
59 lines
Q37632 /Au, /Aw Switches Fail in Medium-Memory Model
C Compiler
5.10 | 5.10
MS-DOS | OS/2
Summary:
The code fragment below demonstrates a problem with Microsoft C
Version 5.10. The problem occurs when you desire SS!=DS in
medium-memory model.
Microsoft has confirmed this to be a problem in Version 5.10. We are
researching this problem and will post new information as it becomes
available.
More Information:
The following code fragment demonstrates the problem:
/*inc(int far *);*/
main()
{
int p=666;
inc(&p);
}
inc(p)
int /*far*/ *p;
{
int *q;
*p+=1;
}
If you compile the above source code with the following command line
options, you will expect the generated code to force DS != SS, as
desired in most Windows programming:
/AM /Au /c /Fc or
/AM /Aw /c /Fc
However, on inspecting the .cod file generated as a result of the /Fc
switch, the assembly code generated fails to force the stack pointer
sp to point at DS.
To work around this problem, note the commented out prototyping of the
function inc() and the commented out cast of the pointer *p to far in
the function inc(). Invoking this prototyping and casting code forces
the compiler to generate the following lines, as can be observed from
the corresponding .cod file:
les bx,DWORD PTR[bp+6]
inc WORD PTR es:[bx].
This process uses the ES register, causing the proper code execution
on a copy of DS held in ES.
Keywords: buglist5.10
Updated 88/11/15 06:14